import os, sys,subprocess

def get_app_dir():
    base_ext = os.path.splitext(os.path.basename(sys.argv[0]))[1]
    # print("argv:",sys.argv)
    app_dir=""
    if base_ext == '.exe':
        # Nuitka 打包或 PyInstaller 打包
        # if hasattr(sys, '_MEIPASS'):
        #     # Nuitka 单文件模式
        #     return sys._MEIPASS
        app_dir= os.path.dirname(sys.argv[0])
    else:
        app_dir= os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    # os.chdir(app_dir)
    
        if app_dir not in sys.path:
            sys.path.append(app_dir)
    # print("sys.path:",sys.path)
    os.chdir(app_dir)
    print("应用目录:",app_dir)
    return app_dir

get_app_dir()

if __name__ == "__main__":
    # 检查并安装必要的模块
    
    pass